package com.vf.cloud.paas.app.master.api.sys.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.vf.cloud.paas.app.master.common.domain.User;
import com.vf.cloud.paas.common.constant.SecurityConstant;
import com.vf.cloud.paas.common.util.JWTUtil;
import com.vf.cloud.paas.common.util.R;

import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@RestController
@RequestMapping("/api/v1/menu")
public class MenuController {
	
	@RequestMapping(value = "/routes1", method = RequestMethod.GET)
	public R<User> info(HttpServletRequest request) {
		try {
			String token = request.getHeader(SecurityConstant.HEADER);
			token = token.replace(SecurityConstant.TOKEN_SPLIT, "");
			String userId = JWTUtil.getClainByName(token, "userId").asString();

			User user = User.dao.findById(userId);
			if (user != null) {
				user.setPassword("");
				return R.ok(user);
			}
			return R.failed(10042, "会话过期，请重新登录！");
		} catch (Exception e) {
			return R.failed(10042, "会话过期，请重新登录！");
		}
	}

	

}
